foreach var in "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" {

display "`var'"
use "Output Data\CIQ_Companies.dta", clear

drop if comp_name == ""
drop if substr(comp_name,1,1) ~= "`var'"

save "Output Data\CIQ_Matching.dta", replace

use "Output Data\GovContracts_Companies.dta", clear

drop if comp_name == ""
drop if substr(comp_name,1,1) ~= "`var'"

egen id_group = group(companyname_gc)

reclink2 comp_name using "Output Data\CIQ_Matching.dta", idm(id_group) idu(companyid) gen(match_score) npairs(1) manytoone

save "Output Data\CIQ_GC_Merge_`var'.dta"
}

display "Numeric"
qui{
use "Output Data\CIQ_Companies.dta", clear

drop if comp_name == ""
drop if substr(comp_name,1,1) == "A"
drop if substr(comp_name,1,1) == "B"
drop if substr(comp_name,1,1) == "C"
drop if substr(comp_name,1,1) == "D"
drop if substr(comp_name,1,1) == "E"
drop if substr(comp_name,1,1) == "F"
drop if substr(comp_name,1,1) == "G"
drop if substr(comp_name,1,1) == "H"
drop if substr(comp_name,1,1) == "I"
drop if substr(comp_name,1,1) == "J"
drop if substr(comp_name,1,1) == "K"
drop if substr(comp_name,1,1) == "L"
drop if substr(comp_name,1,1) == "M"
drop if substr(comp_name,1,1) == "N"
drop if substr(comp_name,1,1) == "O"
drop if substr(comp_name,1,1) == "P"
drop if substr(comp_name,1,1) == "Q"
drop if substr(comp_name,1,1) == "R"
drop if substr(comp_name,1,1) == "S"
drop if substr(comp_name,1,1) == "T"
drop if substr(comp_name,1,1) == "U"
drop if substr(comp_name,1,1) == "V"
drop if substr(comp_name,1,1) == "W"
drop if substr(comp_name,1,1) == "X"
drop if substr(comp_name,1,1) == "Y"
drop if substr(comp_name,1,1) == "Z"

save "Output Data\CIQ_Matching.dta", replace

use "Output Data\GovContracts_Companies.dta", clear

drop if comp_name == ""
drop if substr(comp_name,1,1) == "A"
drop if substr(comp_name,1,1) == "B"
drop if substr(comp_name,1,1) == "C"
drop if substr(comp_name,1,1) == "D"
drop if substr(comp_name,1,1) == "E"
drop if substr(comp_name,1,1) == "F"
drop if substr(comp_name,1,1) == "G"
drop if substr(comp_name,1,1) == "H"
drop if substr(comp_name,1,1) == "I"
drop if substr(comp_name,1,1) == "J"
drop if substr(comp_name,1,1) == "K"
drop if substr(comp_name,1,1) == "L"
drop if substr(comp_name,1,1) == "M"
drop if substr(comp_name,1,1) == "N"
drop if substr(comp_name,1,1) == "O"
drop if substr(comp_name,1,1) == "P"
drop if substr(comp_name,1,1) == "Q"
drop if substr(comp_name,1,1) == "R"
drop if substr(comp_name,1,1) == "S"
drop if substr(comp_name,1,1) == "T"
drop if substr(comp_name,1,1) == "U"
drop if substr(comp_name,1,1) == "V"
drop if substr(comp_name,1,1) == "W"
drop if substr(comp_name,1,1) == "X"
drop if substr(comp_name,1,1) == "Y"
drop if substr(comp_name,1,1) == "Z"

egen id_group = group(companyname_gc)
}

reclink2 comp_name using "Output Data\CIQ_Matching.dta", idm(id_group) idu(companyid) gen(match_score) npairs(1) manytoone

save "Output Data\CIQ_GC_Merge_Num.dta"











use "Output Data\CIQ_GC_Merge_Num.dta", clear

drop if missing(match_score)
drop if match_score < 0.995
drop _merge

foreach var in "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" {
	
merge 1:1 naics_code companyname_gc comp_name Ucomp_name id_group match_score companyid companyname using "Output Data\CIQ_GC_Merge_`var'.dta", nogenerate

drop if missing(match_score)
drop if match_score < 0.995
drop _merge
}



save "Output Data\CIQ_GC_Merge.dta", replace
